//
//  YTRankHeaderView.m
//  yitaicaijing
//
//  Created by DIANGHONG on 2018/8/12.
//  Copyright © 2018年 DIANGHONG. All rights reserved.
//

#import "YTRankHeaderView.h"
#import "YTRankButton.h"

#define calcButtonTag 77777
#define etaiButtonTag 66666
@interface YTRankHeaderView ()
@property (weak, nonatomic) IBOutlet YTRankButton *calcButton;
@property(nonatomic ,strong)YTRankButton *currentBtn;
@end
@implementation YTRankHeaderView

+ (instancetype)headerViewWithFrame:(CGRect)frame
{
    UINib *nib = [UINib nibWithNibName:@"YTRankHeaderView" bundle:nil];
    YTRankHeaderView *view = [nib instantiateWithOwner:nil options:nil][0];
    view.frame = frame;
    return view;
    
    
}

- (void)awakeFromNib
{
    [super awakeFromNib];
    
    self.calcButton.selected = YES;
    self.currentBtn = self.calcButton;
}

- (IBAction)calcOrETAIBtnClick:(YTRankButton *)sender
{
    self.currentBtn.selected = NO;
    sender.selected = YES;
    self.currentBtn = sender;
    
    NSAssert(self.buttonClickBlock != nil, @"buttonClickBlock 不能为nil");
    self.buttonClickBlock((sender.tag == calcButtonTag) ? @"1" : @"2");
}
@end
